<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<t:wrapper title="${title} ${course.name}">
	<jsp:body>
		<div id="navigation">
			<a href="javascript:history.back()" >&laquo; <spring:message code="content.general.back" /></a>
		</div>
		
		<h1>${course.name}</h1>
		<p class="price"><b><spring:message code="course.price"/></b> <spring:message code="content.general.currency"/>${price}</p>
		<b><spring:message code="course.description.title"/></b>
		<div id="course-description">${course.description}</div>
		<!-- Show chapters -->
		<ul>
			<c:forEach items="${chapters}" var="chapter">
				<li>
					<a href="<c:url value="/chapter/view/${chapter.id}"/>">${chapter.title}</a>
				</li>
			</c:forEach>
		</ul>
		<%-- User has to be logged in to see the subscribe button and forum button --%>
		<c:if test="${isLoggedIn}">
			<%-- User has subscribed or is an admin/teacher --%>
			<c:if test="${hasSubscribed or isAdmin or isTeacher}">
				<!-- Forum button -->
				<button onclick="location.href='<c:url value="/course/${course.id}/forum"/>'"><spring:message code="course.forumlink"/></button>
			</c:if>
			<%-- User hasn't subscribed to the course or isn't an admin or teacher --%>
			<c:if test="${!hasSubscribed or !isAdmin or !isTeacher}">
				<!-- Show subscribe button -->
				<button onclick="location.href='<c:url value="/course/subscribe/${course.id}"/>'"><spring:message code="course.button.subscribe"/></button>
			</c:if>
		</c:if>
	</jsp:body>
</t:wrapper>